package com.zzh.interview.config;

import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.stereotype.Component;

/**
 * @author 张 志 豪
 * @version 1.0
 * redis的配置
 */
@Component
public class RedisTemplateConfig {

    @Bean
    private RedisTemplate<String,Object> redisTemplate(RedisConnectionFactory redisConnectionFactory){
        RedisTemplate<String, Object> stringObjectRedisTemplate = new RedisTemplate<>();
        stringObjectRedisTemplate.setConnectionFactory(redisConnectionFactory);
        //设置key和value的序列化,value就默认jdk的序列化就好了
        stringObjectRedisTemplate.setKeySerializer(RedisSerializer.string());
        return stringObjectRedisTemplate;
    }

}
